﻿// -----------------------------------------------------------------------
//  <copyright file="SoftwaresApiIntegrationEventsController.cs" company="LiuliuSoft">
//      Copyright (c) 2025 66SOFT. All rights reserved.
//  </copyright>
//  <site>https://ifs.66soft.net</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025-10-24 23:10</last-date>
// -----------------------------------------------------------------------

using Dapr;
using DaprPlus.Identity.Application.Identity.Users.Commands;

namespace DaprPlus.Identity.Api.Controllers;

[Route("api/integration-events")]
public class SoftwaresApiIntegrationEventsController(IMediator mediator) : ApiControllerBase
{
    private const string _PubSubName = "pubsub";

    [HttpPost("function-auth-changed")]
    [Topic(_PubSubName, "FunctionAuthChanged")]
    public async Task<IActionResult> FunctionAuthChangedEventHandler([FromBody] FunctionAuthSetUserRoleCommand command)
    {
        var result = await mediator.Send(command);
        if (!result.IsSuccess())
        {
            return BadRequest();
        }
        return Accepted();
    }
}
